package com.woniu.car.util;


import java.util.List;

public class ResponseEntity<T> {
    private Integer code;
    private String msg;
    private T object;

    public ResponseEntity(Integer code, String msg, T object) {
        this.code = code;
        this.msg = msg;
        this.object = object;
    }

    public ResponseEntity() {
    }

    //创建单个模型的响应对象
    public static <T> ResponseEntity<T> builder(Class<T> type){
        return new ResponseEntity<T>();
    }
    //创建集合模型的响应对象
    public static <T> ResponseEntity<List<T>> builderList(Class<T> type){
        return new ResponseEntity<List<T>>();
    }

    public Integer getCode() {
        return code;
    }
    //自定义的响应类,连续set对象
    public ResponseEntity<T> setCode(Integer code) {
        this.code = code;
        return this;
    }

    public String getMsg() {
        return msg;
    }
    //自定义的响应类,连续set对象
    public ResponseEntity<T> setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public T getObject() {
        return object;
    }
    //自定义的响应类,连续set对象
    public ResponseEntity<T> setObject(T object) {
        this.object = object;
        return this;
    }
}
